<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>公告</title>

    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/yzl.css"/>

    <style>
        .username-warn {
            font-size: 12px;
            margin: 20px 15px;
        }

        .username-warn > span {
            background-size: 22px 22px;
            background-position: left center;
            background-repeat: no-repeat;
            padding-left: 22px;
        }

        .username-warn > span.big {
            background-image: url(../../image/big/username_icon_warn.png);
        }

        .username-warn > span.small {
            background-image: url(../../image/small/username_icon_warn.png);
        }
    </style>

</head>
<body>
<div id="blank" class="header">
    <div v-back.tapmode class="back"></div>
    <span class="title">家族公告</span>
</div>
<div id="app" class="main-container">
    <!-- <div style="background:#ffffff;margin-top:20px;padding:20px 20px 0px 20px;color:#999999;font-size:13px">
      <div>免费翻译服务可提供简体中文和另外 100 多种语言之间的互译功能,可让您即时翻译字词、短语和网页内容</div>
      <div style="padding:10px;text-align:right">小明编辑于2019-12-1</div>
    </div> -->
    <div style="background:#ffffff;margin-top:20px;padding:20px">
      <textarea id="input" v-model="announce"  placeholder="请输入群公告100字以内" style="width:100%;height:60px;outline: none;padding-top:10px">
           </textarea>
    </div>
    <a class="btn-commit" style="background:#33375E" v-myclick="updateannonce" >提交</a>

</div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script>
    var user;
    apiready = function () {
        setBSImg();
        new Vue({
            el: '#blank'
        });
        user = JSON.parse(getPrefs('user'));
        initApp();
        api.parseTapmode();
        addListeners();
    };

    function initApp() {
        var vm = new Vue({
            el: '#app',
            data: {
                announce: api.pageParam.notice,
                BSImg: {
                    big: Vue.BSImg == 'big',
                    small: Vue.BSImg == 'small'
                }
            },
            watch:{
                announce:function (n, o) {
                    this.nameByte = n.replace(/[^\x00-\xff]/g,"xx").length;
                    if(this.nameByte > 200){
                        this.announce = o;
                    }
                }
            },
            methods: {
                updateannonce: function () {
                  // if(!this.announce.trim()){
                  //   alert('公告不能为空');
                  //   return;
                  // }
                    showProgress();
                    var data = {
                        member_id: getPrefs('member_id'),
                        clan_id:api.pageParam.group_id,
                        notice: this.announce==null?'':this.announce
                    };
                    var callback = function (ret) {
                      api.sendEvent({
                        name : 'updateClan',
                      });
                        // onPageEnd();
                        api.closeWin();
                    };
                    pinet.post(URL.updateClan, data, callback);
                },
            },
            mounted:function () {
            }
        });
    }

    function addListeners() {
        api.addEventListener({
            name: 'viewappear'
        }, function () {
            onPageStart();
        });

        api.addEventListener({
            name: 'viewdisappear'
        }, function (ret, err) {
            onPageEnd();
        });

        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            onPageEnd();
            api.closeWin();
        });
    }
</script>
</html>
